﻿@model NewLife.CMX.IInfo
@using System.Reflection
@using XCode
@using XCode.Configuration
@using NewLife.CMX;
@using NewLife.CMX.Web;
@{
    var fact = ViewBag.Factory as IEntityOperate;
    var entity = Model as IEntity;
    var isNew = entity.IsNullKey;
    var inf = Model as IInfo;
    var article = inf.Ext as IArticle;
}
<div class="panel panel-default">
    <div class="form-horizontal">
        @Html.Partial("_Form_Header", entity)
        @using (Html.BeginForm((isNew ? "Add" : "Edit"), null, new { id = Model[fact.Unique.Name] }))
        {
            @Html.AntiForgeryToken()
            @Html.ValidationSummary()
            @Html.Partial("_Form_Title", entity)
            <div class="form-group">
                <label class="control-label col-sm-2">来源</label>
                <div class="col-sm-2">
                    @Html.ForDropDownList(Article._.SourceID, Source.FindAllVisible(), null, false)
                </div>
                <div class="col-sm-3">
                    <label class="control-label col-md-4">名称</label>
                    <div class="col-md-8">
                        @Html.ForEditor(Article._.SourceName, entity)
                    </div>
                </div>
                <div class="col-sm-3">
                    <label class="control-label col-md-4">地址</label>
                    <div class="col-md-8">
                        @Html.ForEditor(Article._.SourceUrl, entity)
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2 col-md-2">内容</label>
                <div class="col-sm-10 col-md-6">
                    @Html.Partial("_Form_Content", entity)
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">摘要</label>
                <div class="col-md-6">
                    @Html.TextArea("Summary", inf.Summary, 5, 100, null)
                </div>
            </div>
            <div class="form-group">
                @{ var item = Article._.Top;}
                <label class="control-label col-md-2">@item.DisplayName</label>
                <div class="col-md-1">
                    @Html.ForEditor(item, entity)
                </div>
                @{ item = Article._.Recommend;}
                <label class="control-label col-md-1">@item.DisplayName</label>
                <div class="col-md-1">
                    @Html.ForEditor(item, entity)
                </div>
                @{ item = Article._.Hot;}
                <label class="control-label col-md-1">@item.DisplayName</label>
                <div class="col-md-1">
                    @Html.ForEditor(item, entity)
                </div>
                @{ item = Article._.Slide;}
                <label class="control-label col-md-1">@item.DisplayName</label>
                <div class="col-md-1">
                    @Html.ForEditor(item, entity)
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">封面</label>
                <div class="col-md-6">
                    @Html.ForEditor(Article._.Cover, entity)
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">发布时间</label>
                <div class="col-md-2">
                    <div class="input-group">
                        @Html.ForEditor("PublishTime", inf.PublishTime)
                    </div>
                </div>
            </div>
            @Html.Partial("_Form_Footer", entity)
                    @Html.Partial("_Form_Action", entity)
                    }
    </div>
</div>
<script type="text/javascript">
    $("#@Article._.SourceID").change(
           function () {
               var v = $("#@Article._.SourceID").val();
               $.ajax({
                   type: "Post",//使用get方法访问后台
                   dataType: "json",//返回json格式的数据
                   url: '/CMS/Article/GetSource/' + v,//要访问的后台地址
                   success: function (msg) {//msg为返回的数据，在这里做数据绑定
                       $("#@Article._.SourceName").attr("value", msg.Name);
                       $("#@Article._.SourceUrl").attr("value", msg.Url);
                   }
               });
           });
</script>